-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ship codegen-generated specs #566
Conversation
packages/create-react-native-library/src/utils/patchExampleAppCodegen.ts
Outdated
Show resolved
Hide resolved
move the codegen script and codegen patching into bob. |
70dc19f
to
3425532
Compare
2aa76c8
to
d0b1ad2
Compare
I think it would be great to explain the advantages (or disadvantages) of this approach. My understand for example if you want to make android side work with old arch, the codgen generated interfaces, delegates can be usefull to be shipped with the project. |
packages/create-react-native-library/templates/native-view-new/react-native.config.js
Outdated
Show resolved
Hide resolved
packages/create-react-native-library/src/utils/patchExampleAppCodegen.ts
Outdated
Show resolved
Hide resolved
72c5efe
to
07df18c
Compare
d1e0764
to
39d2a07
Compare
Summary
So far with the new architecture-supported templates, we've been generating libraries that didn't ship their codegen-generated specs. This means the library's users had to build the codegen specs on their end (this was done implicitly). With this, the codegen-generated specs are generated at the build time and they are shipped with the library.
I've followed this guide from the React Native new arch working group.
Making sure example app builds are triggering codegen
An important problem to figure out was to make sure the codegen-generated specs were being built with each native build of the example app. To do that,
create-react-native-library
now modifies non-legacy example apps and adds:example/android/build.gradle
that's triggered before each native build.pre_install
hook toexample/ios/Podfile
that's triggered when user callspod install
.These modifications make sure
yarn codegen
is called on the repo root to generate the codegen specs.Notes
react-native codegen
is called, the generated Java code doesn't follow thecodegenConfig.android.javaPackageName
property in thepackage.json
. This means the generated Java files are stored in a default location with the wrong package name. To fix it, I've added a script that moves the codegen-generated files into the correct place. You can check codegen - javaPackageName is ignored with includesGeneratedCode and react-native codegen facebook/react-native#45079 to see more.Test plan
Test if Android builds trigger codegen
create-react-native-library
android/generated
.Test if installing pods triggers codegen
create-react-native-library
pod install
inexample/ios
ios/generated
.Test if iOS builds trigger codegen
create-react-native-library
pod install
inexample/ios
ios/generated
since that's generated by the pod install stepios/generated
.Test if building the library triggers codegen
yarn prepare
to emulate the library release processyarn pack
package.tgz
ios/generated
, andandroid/generated
in the generated package.